import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
} from '@nestjs/common'
import { ApiOperation, ApiTags } from '@nestjs/swagger'
import { DepartmentService } from './department.service'
import { CreateDepartmentDto } from './dto/create-department.dto'
import { UpdateDepartmentDto } from './dto/update-department.dto'

@ApiTags('部门管理')
@Controller('api/system/departments')
export class DepartmentController {
  constructor(private readonly departmentService: DepartmentService) {}

  @ApiOperation({
    summary: '新增部门',
  })
  @Post()
  create(@Body() createDepartmentDto: CreateDepartmentDto) {
    return this.departmentService.create(createDepartmentDto)
  }

  @ApiOperation({
    summary: '查询部门',
  })
  @Get()
  findAll() {
    return this.departmentService.findAll()
  }

  @ApiOperation({
    summary: '查询部门详情',
  })
  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.departmentService.findOne(+id)
  }

  @ApiOperation({
    summary: '修改部门',
  })
  @Patch(':id')
  update(
    @Param('id') id: string,
    @Body() updateDepartmentDto: UpdateDepartmentDto,
  ) {
    return this.departmentService.update(+id, updateDepartmentDto)
  }

  @ApiOperation({
    summary: '删除部门',
  })
  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.departmentService.remove(+id)
  }
}
